#ifndef JWAITCONDITION_H
#define JWAITCONDITION_H

#include "jthreadpool_global.h"
#include "jmutex.h"
#include "jreadwritelock.h"
#include <limits>

class JWaitConditionPrivate;

/**
 * @brief The JWaitCondition class
 */
class JTHREADPOOL_EXPORT JWaitCondition
{
public:
    /**
     * @brief JWaitCondition
     */
    JWaitCondition();
    ~JWaitCondition();

    /**
     * @brief wait
     * @param mutex
     * @param time
     * @return
     */
    bool wait(JMutex *mutex, unsigned long time = ULONG_MAX);

    /**
     * @brief wait
     * @param readWriteLock
     * @param time
     * @return
     */
    bool wait(JReadWriteLock *readWriteLock, unsigned long time = ULONG_MAX);

    /**
     * @brief wakeOne
     */
    void wakeOne();

    /**
     * @brief wakeAll
     */
    void wakeAll();

private:
    J_DISABLE_COPY(JWaitCondition)
    JWaitConditionPrivate *d;
};

#endif // JWAITCONDITION_H
